package com.caojing.haolemai.ui.category.categoryadapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.caojing.haolemai.R;
import com.caojing.haolemai.bean.ContentBean;

/** 
 * @author 作者 E-mail: 
 * @version 创建时间：2016年3月29日 下午5:27:41 
 * 类说明 
 */
public class GvdrawerAdapter extends BaseAdapter{
	
	private List<?> list = new ArrayList<>();
	private Context context;
	private int selectItem=-1;
	
	public GvdrawerAdapter() {
	}
	public GvdrawerAdapter(Context context, List<ContentBean.ResultsBean.FiltersBean> list ) {
		this.list=list;
		this.context=context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHodler viewHodler;

		if (convertView==null){
			convertView =LayoutInflater.from(context).inflate(R.layout.drawer_list_gv_item, null);
			viewHodler=new ViewHodler(convertView);
			convertView.setTag(viewHodler);
		}else {
			viewHodler= (ViewHodler) convertView.getTag();
		}
		Object o = list.get(position);



//		tv.setText((CharSequence) list.get(position));
//		if (!list.get(position).contains("更多") && !list.get(position).contains("收起")) {
//			if (position == selectItem) {
//                tv.setTextColor(context.getResources().getColor(R.color.colorAccent));
//
//            } else {
//                tv.setBackgroundResource(R.mipmap.bg_icon);
//                tv.setTextColor(context.getResources().getColor(R.color.colorAccent));
//            }
//		} else {
//			tv.setTextColor(context.getResources().getColor(R.color.colorAccent));
//		}
//
		return convertView;
	}
//	public void setSelectItem(int position) {
//		selectItem=position;
//	}

	static class ViewHodler{
		private TextView tv;
		public ViewHodler(View view){
			 tv = (TextView) view.findViewById(R.id.tv);
		}

	}
}
